<!--
 * @Author: WuFeng <763467339@qq.com>
 * @Date: 2022-04-12 18:47:17
 * @LastEditTime: 2022-07-26 17:24:21
 * @LastEditors: WuFeng <763467339@qq.com>
 * @Description: 新建 / 编辑 页面
 * @FilePath: \vue3-element-plus-web\src\views\SysManage\SysLog\components\sysLog\create.vue
 * Copyright 版权声明
-->
<template>
  <div class="">
    <el-form
      :rules="rules"
      ref="dataForm"
      :model="temp"
      label-width="80px"
      style='width:100%;'
    >
      <el-form-item label="编号" prop="${id}">
        <el-input v-model="temp.id" placeholder="请输入编号"></el-input>
      </el-form-item>
      <el-form-item label="租户ID" prop="${tenantId}">
        <el-input v-model="temp.tenantId" placeholder="请输入租户ID"></el-input>
      </el-form-item>
      <el-form-item label="服务ID" prop="${serviceId}">
        <el-input v-model="temp.serviceId" placeholder="请输入服务ID"></el-input>
      </el-form-item>
      <el-form-item label="服务器名" prop="${serverHost}">
        <el-input v-model="temp.serverHost" placeholder="请输入服务器名"></el-input>
      </el-form-item>
      <el-form-item label="服务器IP地址" prop="${serverIp}">
        <el-input v-model="temp.serverIp" placeholder="请输入服务器IP地址"></el-input>
      </el-form-item>
      <el-form-item label="服务器环境" prop="${env}">
        <el-input v-model="temp.env" placeholder="请输入服务器环境"></el-input>
      </el-form-item>
      <el-form-item label="日志类型" prop="${type}">
        <el-input v-model="temp.type" placeholder="请输入日志类型"></el-input>
      </el-form-item>
      <el-form-item label="日志标题" prop="${title}">
        <el-input v-model="temp.title" placeholder="请输入日志标题"></el-input>
      </el-form-item>
      <el-form-item label="操作方式" prop="${method}">
        <el-input v-model="temp.method" placeholder="请输入操作方式"></el-input>
      </el-form-item>
      <el-form-item label="请求URI" prop="${requestUri}">
        <el-input v-model="temp.requestUri" placeholder="请输入请求URI"></el-input>
      </el-form-item>
      <el-form-item label="用户代理" prop="${userAgent}">
        <el-input v-model="temp.userAgent" placeholder="请输入用户代理"></el-input>
      </el-form-item>
      <el-form-item label="操作IP地址" prop="${remoteIp}">
        <el-input v-model="temp.remoteIp" placeholder="请输入操作IP地址"></el-input>
      </el-form-item>
      <el-form-item label="方法类" prop="${methodClass}">
        <el-input v-model="temp.methodClass" placeholder="请输入方法类"></el-input>
      </el-form-item>
      <el-form-item label="方法名" prop="${methodName}">
        <el-input v-model="temp.methodName" placeholder="请输入方法名"></el-input>
      </el-form-item>
      <el-form-item label="操作提交的数据" prop="${params}">
        <el-input v-model="temp.params" placeholder="请输入操作提交的数据"></el-input>
      </el-form-item>
      <el-form-item label="执行时间" prop="${time}">
        <el-input v-model="temp.time" placeholder="请输入执行时间"></el-input>
      </el-form-item>
      <el-form-item label="创建者" prop="${createBy}">
        <el-input v-model="temp.createBy" placeholder="请输入创建者"></el-input>
      </el-form-item>
      <el-form-item label="创建时间" prop="${createTime}">
        <el-input v-model="temp.createTime" placeholder="请输入创建时间"></el-input>
      </el-form-item>
      <el-form-item label="堆栈" prop="${stackTrace}">
        <el-input v-model="temp.stackTrace" placeholder="请输入堆栈"></el-input>
      </el-form-item>
      <el-form-item label="异常信息" prop="${message}">
        <el-input v-model="temp.message" placeholder="请输入异常信息"></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { ENABLED_STATE_ENUM } from '@/config'

export default {
  name: 'Create',
  computed: {
    ...mapGetters([
      'drawerCurrent'
    ]),
    drawerType: function() {
      return this.drawerCurrent.drawerType
    }
  },
  components: {

  },
  data() {
    return {
      temp: {
        state: 1
      },
      rules: {
        id: [
          { required: true, message: '请输入编号', trigger: 'change' }
        ],
        tenantId: [
          { required: true, message: '请输入租户ID', trigger: 'change' }
        ],
        serviceId: [
          { required: true, message: '请输入服务ID', trigger: 'change' }
        ],
        serverHost: [
          { required: true, message: '请输入服务器名', trigger: 'change' }
        ],
        serverIp: [
          { required: true, message: '请输入服务器IP地址', trigger: 'change' }
        ],
        env: [
          { required: true, message: '请输入服务器环境', trigger: 'change' }
        ],
        type: [
          { required: true, message: '请输入日志类型', trigger: 'change' }
        ],
        title: [
          { required: true, message: '请输入日志标题', trigger: 'change' }
        ],
        method: [
          { required: true, message: '请输入操作方式', trigger: 'change' }
        ],
        requestUri: [
          { required: true, message: '请输入请求URI', trigger: 'change' }
        ],
        userAgent: [
          { required: true, message: '请输入用户代理', trigger: 'change' }
        ],
        remoteIp: [
          { required: true, message: '请输入操作IP地址', trigger: 'change' }
        ],
        methodClass: [
          { required: true, message: '请输入方法类', trigger: 'change' }
        ],
        methodName: [
          { required: true, message: '请输入方法名', trigger: 'change' }
        ],
        params: [
          { required: true, message: '请输入操作提交的数据', trigger: 'change' }
        ],
        time: [
          { required: true, message: '请输入执行时间', trigger: 'change' }
        ],
        createBy: [
          { required: true, message: '请输入创建者', trigger: 'change' }
        ],
        createTime: [
          { required: true, message: '请输入创建时间', trigger: 'change' }
        ],
        stackTrace: [
          { required: true, message: '请输入堆栈', trigger: 'change' }
        ],
        message: [
          { required: true, message: '请输入异常信息', trigger: 'change' }
        ]
      },
      // 状态列表
      statusList: ENABLED_STATE_ENUM
    }
  },
  watch: {
    // 表单内容体
    temp: {
      handler: function(val, oldVal) {
      },
      deep: true
    }
  },
  created() {
    // console.log('-----------', this.drawerCurrent)
    // 列表传过来的数据
    const temp = this.drawerCurrent.params.row
    this.temp = Object.assign({}, this.temp, temp)
    // *******************如果是 【编辑】 需要从接口数据的话执行一下操作
    if (this.drawerType === 'UPDATE') {
      // drawer loadding 状态 打开
      this.$store.dispatch('SetDrawerloading', true)
      setTimeout(() => {
        // drawer loadding 状态 关闭
        this.$store.dispatch('SetDrawerloading', false)
      }, 500)
    }
  },
  mounted() {

  },
  methods: {
    // 提交表单
    submitForm() {
      return this.$refs['dataForm'].validate()
    },
    // 获取表单数据
    getFormData() {
      return this.temp
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
</style>
